/*
 * CretaeAccount.java
 *
 * Created on April 21, 2009, 7:22 PM
 */

package ui;

import GoMail.MailUser;
import GoMail.MailUserOperations;
import account.Account;
import folders2.RootFolders2;
import folders2.UserFileOperation2;
import folders2.UsersFile2;
import java.awt.Toolkit;
import java.io.IOException;
import java.util.Calendar;
import validation.*;
/**
 *
 * @author  MI
 */
public class CretaeAccount extends javax.swing.JFrame {

    /** Creates new form CretaeAccount */
    public CretaeAccount() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jTextField2 = new javax.swing.JTextField();
        jPasswordField1 = new javax.swing.JPasswordField();
        jPasswordField2 = new javax.swing.JPasswordField();
        jTextField3 = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jTextField4 = new javax.swing.JTextField();
        jTextField5 = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jTextField6 = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        jTextField7 = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        jTextField9 = new javax.swing.JTextField();
        jLabel21 = new javax.swing.JLabel();
        jTextField10 = new javax.swing.JTextField();
        jLabel22 = new javax.swing.JLabel();
        jRadioButton1 = new javax.swing.JRadioButton();
        jRadioButton2 = new javax.swing.JRadioButton();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        jTextField11 = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jLabel27 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jLabel28 = new javax.swing.JLabel();
        jComboBox2 = new javax.swing.JComboBox();
        jLabel29 = new javax.swing.JLabel();
        jComboBox3 = new javax.swing.JComboBox();
        jLabel30 = new javax.swing.JLabel();
        jLabel31 = new javax.swing.JLabel();
        jLabel32 = new javax.swing.JLabel();
        jLabel33 = new javax.swing.JLabel();
        jLabel34 = new javax.swing.JLabel();
        jLabel35 = new javax.swing.JLabel();
        jLabel36 = new javax.swing.JLabel();
        jLabel37 = new javax.swing.JLabel();
        jLabel38 = new javax.swing.JLabel();
        jLabel39 = new javax.swing.JLabel();
        jLabel40 = new javax.swing.JLabel();
        jLabel41 = new javax.swing.JLabel();
        jLabel42 = new javax.swing.JLabel();
        jLabel43 = new javax.swing.JLabel();
        jLabel44 = new javax.swing.JLabel();
        jLabel45 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Create account...");
        setIconImage(Toolkit.getDefaultToolkit().getImage(NewJFrame.class.getResource("/ui/logo.png")));
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ui/background.png"))); // NOI18N
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 760, 130));

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel2.setText("Go! ID:");
        jLabel2.setName("lblId"); // NOI18N
        getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 140, -1, 20));

        jLabel3.setText("@go.com");
        jLabel3.setName("lblDomain"); // NOI18N
        getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 140, -1, 20));

        jTextField1.setText("example:mark2009");
        jTextField1.setName("txtId"); // NOI18N
        jTextField1.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jTextField1FocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField1FocusLost(evt);
            }
        });
        getContentPane().add(jTextField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 140, 110, 20));

        jLabel4.setText("Password:");
        getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 170, -1, 20));

        jLabel5.setText("Confirm password:");
        getContentPane().add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 170, -1, 20));

        jTextField2.setName("txtFirstName"); // NOI18N
        jTextField2.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField2FocusLost(evt);
            }
        });
        getContentPane().add(jTextField2, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 380, 180, -1));

        jPasswordField1.setName("txtPassword"); // NOI18N
        jPasswordField1.addCaretListener(new javax.swing.event.CaretListener() {
            public void caretUpdate(javax.swing.event.CaretEvent evt) {
                jPasswordField1CaretUpdate(evt);
            }
        });
        getContentPane().add(jPasswordField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 170, 190, -1));

        jPasswordField2.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jPasswordField2FocusLost(evt);
            }
        });
        getContentPane().add(jPasswordField2, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 170, 190, -1));

        jTextField3.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField3FocusLost(evt);
            }
        });
        getContentPane().add(jTextField3, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 290, 210, -1));

        jLabel6.setText("First name:");
        getContentPane().add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 260, -1, 20));

        jLabel7.setText("Last name:");
        getContentPane().add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 260, -1, 20));

        jLabel8.setText("Password strength:");
        getContentPane().add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 200, -1, -1));

        jLabel9.setText("Weak");
        getContentPane().add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 220, -1, -1));
        jLabel9.setVisible(false);

        jLabel10.setText("Moderate");
        getContentPane().add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 220, -1, -1));
        jLabel10.setVisible(false);

        jLabel11.setText("Strong");
        getContentPane().add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 220, -1, -1));
        jLabel11.setVisible(false);

        jTextField4.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField4FocusLost(evt);
            }
        });
        getContentPane().add(jTextField4, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 260, 170, -1));

        jTextField5.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField5FocusLost(evt);
            }
        });
        getContentPane().add(jTextField5, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 260, 170, -1));

        jLabel12.setText("*Password of minimum 6 characters");
        getContentPane().add(jLabel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 200, -1, -1));

        jLabel13.setForeground(new java.awt.Color(204, 0, 0));
        jLabel13.setText("*Password must be more than 6 characters");
        getContentPane().add(jLabel13, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 220, -1, -1));
        jLabel13.setVisible(false);

        jLabel14.setForeground(new java.awt.Color(204, 0, 0));
        jLabel14.setText("*Password doesn't match");
        getContentPane().add(jLabel14, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 240, -1, -1));
        jLabel14.setVisible(false);

        jLabel15.setText("Alternative email:");
        getContentPane().add(jLabel15, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 290, -1, 20));

        jLabel16.setForeground(new java.awt.Color(204, 0, 0));
        jLabel16.setText("*Enter valid e-mail");
        getContentPane().add(jLabel16, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 290, -1, -1));
        jLabel16.setVisible(false);

        jLabel17.setText("Country:");
        getContentPane().add(jLabel17, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 380, -1, 20));

        jLabel18.setText("City:");
        getContentPane().add(jLabel18, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 380, -1, -1));

        jTextField6.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField6FocusLost(evt);
            }
        });
        getContentPane().add(jTextField6, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 380, 180, -1));

        jLabel19.setText("Security question:");
        getContentPane().add(jLabel19, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 330, -1, -1));

        jTextField7.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField7FocusLost(evt);
            }
        });
        getContentPane().add(jTextField7, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 330, 210, -1));

        jLabel20.setText("Secret answer:");
        getContentPane().add(jLabel20, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 330, -1, 20));

        jTextField9.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField9FocusLost(evt);
            }
        });
        getContentPane().add(jTextField9, new org.netbeans.lib.awtextra.AbsoluteConstraints(500, 330, 200, -1));

        jLabel21.setText("Postal code:");
        getContentPane().add(jLabel21, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 420, -1, 20));

        jTextField10.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField10FocusLost(evt);
            }
        });
        getContentPane().add(jTextField10, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 420, 80, -1));

        jLabel22.setFont(new java.awt.Font("DejaVu Sans", 1, 13));
        jLabel22.setText("Gender:");
        getContentPane().add(jLabel22, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 460, -1, 20));

        buttonGroup1.add(jRadioButton1);
        jRadioButton1.setText("Male");
        jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton1ActionPerformed(evt);
            }
        });
        getContentPane().add(jRadioButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 460, -1, -1));

        buttonGroup1.add(jRadioButton2);
        jRadioButton2.setText("Female");
        jRadioButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton2ActionPerformed(evt);
            }
        });
        getContentPane().add(jRadioButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(170, 460, -1, -1));

        jLabel23.setFont(new java.awt.Font("DejaVu Sans", 1, 13));
        jLabel23.setText("Birth date:");
        getContentPane().add(jLabel23, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 460, -1, -1));

        jLabel24.setText("Security image:");
        getContentPane().add(jLabel24, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 530, -1, -1));

        jLabel25.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ui/hipImageDirect.srf.jpg"))); // NOI18N
        jLabel25.setText("cdc");
        getContentPane().add(jLabel25, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 510, 220, 60));

        jLabel26.setText("Type image characters here:");
        getContentPane().add(jLabel26, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 590, -1, 20));

        jTextField11.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextField11FocusLost(evt);
            }
        });
        getContentPane().add(jTextField11, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 590, 220, -1));

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ui/btnSubmit1.png"))); // NOI18N
        jButton1.setToolTipText("Create account");
        jButton1.setBorder(null);
        jButton1.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/ui/btnSubmit2.png"))); // NOI18N
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });
        getContentPane().add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 640, 140, 50));

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ui/btnCancel1.png"))); // NOI18N
        jButton2.setToolTipText("Cancel");
        jButton2.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/ui/btnCancel2.png"))); // NOI18N
        jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton2MouseClicked(evt);
            }
        });
        getContentPane().add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 640, 140, 50));

        jLabel27.setText("Year:");
        getContentPane().add(jLabel27, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 460, -1, 20));

        String[] yearList=new String[Calendar.getInstance().get(Calendar.YEAR)-1908];
        int index=0;
        for (int i=Calendar.getInstance().get(Calendar.YEAR);i>=1909;i--){
            yearList[index]=""+i;
            index++;
        }
        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(yearList));
        jComboBox1.setSelectedItem(Calendar.getInstance().get(Calendar.YEAR));
        getContentPane().add(jComboBox1, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 460, -1, 20));

        jLabel28.setText("Month:");
        getContentPane().add(jLabel28, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 460, 50, 20));

        String[] monthList={"1","2","3","4","5","6","7","8","9","10","11","12"};
        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(monthList));
        jComboBox2.setSelectedItem(Calendar.getInstance().get(Calendar.MONTH));
        jComboBox2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox2ActionPerformed(evt);
            }
        });
        getContentPane().add(jComboBox2, new org.netbeans.lib.awtextra.AbsoluteConstraints(540, 460, -1, 20));

        jLabel29.setText("Day:");
        getContentPane().add(jLabel29, new org.netbeans.lib.awtextra.AbsoluteConstraints(600, 460, -1, 20));

        jComboBox3.setSelectedItem(Calendar.getInstance().get(Calendar.DATE));
        jComboBox3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox3ActionPerformed(evt);
            }
        });
        getContentPane().add(jComboBox3, new org.netbeans.lib.awtextra.AbsoluteConstraints(630, 460, -1, 20));

        jLabel30.setForeground(new java.awt.Color(204, 0, 0));
        jLabel30.setText("*Invalid ID");
        getContentPane().add(jLabel30, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 140, -1, 20));
        jLabel30.setVisible(false);

        jLabel31.setForeground(new java.awt.Color(204, 0, 0));
        jLabel31.setText("*ID is too short");
        getContentPane().add(jLabel31, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 140, -1, 20));
        jLabel31.setVisible(false);

        jLabel32.setForeground(new java.awt.Color(204, 0, 0));
        jLabel32.setText("*Name is too short");
        getContentPane().add(jLabel32, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 260, -1, 20));
        jLabel32.setVisible(false);

        jLabel33.setForeground(new java.awt.Color(204, 0, 0));
        jLabel33.setText("*Name contains invalid chracters");
        getContentPane().add(jLabel33, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 280, -1, -1));
        jLabel33.setVisible(false);

        jLabel34.setForeground(new java.awt.Color(204, 0, 0));
        jLabel34.setText("*Invalid security question");
        getContentPane().add(jLabel34, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 360, -1, -1));
        jLabel34.setVisible(false);

        jLabel35.setForeground(new java.awt.Color(204, 0, 0));
        jLabel35.setText("*Security question is too short");
        getContentPane().add(jLabel35, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 360, -1, -1));
        jLabel35.setVisible(false);

        jLabel36.setText("?");
        getContentPane().add(jLabel36, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 330, -1, -1));

        jLabel37.setForeground(new java.awt.Color(204, 0, 0));
        jLabel37.setText("*Invalid country");
        getContentPane().add(jLabel37, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 400, -1, 20));
        jLabel37.setVisible(false);

        jLabel38.setForeground(new java.awt.Color(204, 0, 0));
        jLabel38.setText("*Country name is too short");
        getContentPane().add(jLabel38, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 400, -1, 20));
        jLabel38.setVisible(false);

        jLabel39.setForeground(new java.awt.Color(204, 0, 0));
        jLabel39.setText("*City contains invalid characters");
        getContentPane().add(jLabel39, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 380, -1, -1));
        jLabel39.setVisible(false);

        jLabel40.setForeground(new java.awt.Color(204, 0, 0));
        jLabel40.setText("*City name is too short");
        getContentPane().add(jLabel40, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 400, -1, -1));
        jLabel40.setVisible(false);

        jLabel41.setForeground(new java.awt.Color(204, 0, 0));
        jLabel41.setText("*Invalid postal code");
        getContentPane().add(jLabel41, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 420, -1, 20));
        jLabel41.setVisible(false);

        jLabel42.setForeground(new java.awt.Color(204, 0, 0));
        jLabel42.setText("*Type the security characters right please");
        getContentPane().add(jLabel42, new org.netbeans.lib.awtextra.AbsoluteConstraints(540, 590, -1, -1));
        jLabel42.setVisible(false);

        jLabel43.setForeground(new java.awt.Color(204, 0, 0));
        jLabel43.setText("*Invalid security answer");
        getContentPane().add(jLabel43, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 360, -1, -1));
        jLabel43.setVisible(false);

        jLabel44.setForeground(new java.awt.Color(204, 0, 0));
        jLabel44.setText("*Security answer is too short");
        getContentPane().add(jLabel44, new org.netbeans.lib.awtextra.AbsoluteConstraints(600, 360, -1, -1));
        jLabel44.setVisible(false);

        jLabel45.setForeground(new java.awt.Color(255, 51, 0));
        jLabel45.setText("*Sorry..ID already exist");
        getContentPane().add(jLabel45, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 720, -1, -1));
        jLabel45.setVisible(false);

        pack();
    }// </editor-fold>//GEN-END:initComponents

 int idStatus;
 int passStatus;
 int nameStatus;
 int secAnsStatus;
 int secQnStatus;
 int emailStatus;
 int countryStatus;
 int cityStatus;
 int secImageStatus;
 int postalCodeStatus;
 int genderStatus;
 int generalStatus;

private void jPasswordField1CaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_jPasswordField1CaretUpdate
    // TODO add your handling code here:
    int strength=Validate.passStren(new String(jPasswordField1.getPassword()),6);
    if (strength==0)
    {
        jLabel9.setVisible(true);
        jLabel10.setVisible(false);
        jLabel11.setVisible(false);
    }else if(strength==1)
    {
        jLabel9.setVisible(false);
        jLabel10.setVisible(true);
        jLabel11.setVisible(false);
    }else{
        jLabel9.setVisible(false);
        jLabel10.setVisible(false);
        jLabel11.setVisible(true);
    }
}//GEN-LAST:event_jPasswordField1CaretUpdate

private void jPasswordField2FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jPasswordField2FocusLost
    // TODO add your handling code here:
    String password=new String(jPasswordField1.getPassword());
    String passConfirm=new String(jPasswordField2.getPassword());
    jLabel13.setVisible(false);
    jLabel14.setVisible(false);
    int status=Validate.confirmPassword(password, passConfirm, 6);
    if (status==-1){
        jLabel14.setVisible(true);
        passStatus=-1;
    }else if (status==-2){
        passStatus=-1;
        jLabel13.setVisible(true);
    }else
        passStatus=0;
}//GEN-LAST:event_jPasswordField2FocusLost

private void jTextField3FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField3FocusLost
    // TODO add your handling code here:
    jLabel16.setVisible(false);
    if(Validate.validateEmail(jTextField3.getText())==-1){
        jLabel16.setVisible(true);
        emailStatus=-1;
    }else
        emailStatus=0;
}//GEN-LAST:event_jTextField3FocusLost

private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseClicked
    // TODO add your handling code here:
    System.exit(0);
}//GEN-LAST:event_jButton2MouseClicked
String[] dayList;
private void jComboBoxChange()
{
    int itemIndex=jComboBox2.getSelectedIndex();
    dayList=Validate.dayList(itemIndex,jComboBox1.getSelectedIndex());
    jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(dayList));

}

private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox2ActionPerformed
    // TODO add your handling code here:
    jComboBoxChange();
    month=(String)jComboBox2.getSelectedItem();
}//GEN-LAST:event_jComboBox2ActionPerformed
    String day;
    String month;
    String year;

private void jTextField1FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField1FocusGained
    // TODO add your handling code here:
    jTextField1.setText("");
}//GEN-LAST:event_jTextField1FocusGained

private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
    // TODO add your handling code here:
    genderStatus=Validate.validateGender(gender);
    generalStatus=(passStatus+nameStatus+secQnStatus+secAnsStatus+emailStatus+countryStatus+cityStatus+secImageStatus+postalCodeStatus+genderStatus+idStatus);
    if (generalStatus >= 0) {
        String id, password, firstName, lastName, altEmail, secQn, secAns, country, city, postalCode, gender, birthdate;
        id = jTextField1.getText();
        password = new String(jPasswordField1.getPassword());
        firstName = jTextField5.getText();
        lastName = jTextField4.getText();
        altEmail = jTextField3.getText();
        secQn = jTextField7.getText();
        secAns = jTextField9.getText();
        country = jTextField2.getText();
        city = jTextField6.getText();
        postalCode = jTextField10.getText();
        gender = this.gender;
        if (day.length() == 1) {
            day = "0" + day;
        }
        if (month.length() == 1) {
            month = "0" + month;
        }
        birthdate = year + "-" + month + "-" + day;
        String[] list = {firstName, lastName, id, password, altEmail, city, country, birthdate, gender, secQn, secAns, postalCode};
        int status=0;
        try{
            status=new UserFileOperation2().mailExist(id,password);
        }catch (IOException ex){
            ex.printStackTrace();
        }
        if (status == -1) {
            new Account().setAllAccountData(list);
            try {
                UserFileOperation2 users = new UserFileOperation2();
                users.readUsersFile();
                //i should make chech in this step of root folders
                RootFolders2 rootFolders = new RootFolders2();
                if (!rootFolders.getRoot().getMyFile().exists()) {
                    rootFolders.createRootFolders();
                }
                MailUserOperations newUser = null;
                Account userAccount = new Account();
                userAccount.setAllAccountData(list);
                UsersFile2 userData = new UsersFile2(userAccount.getUserName(), userAccount.getPassword());
                users.addNewUser(userData);         //add new user to users file
                users.getUsers().add(new UsersFile2(userAccount.getUserName(), userAccount.getPassword()));
                MailUser userMail = new MailUser(rootFolders.getRoot().getMyFile(), userAccount);//////////////?????????????
                userMail.getUserAccount().writeAccountData(userMail.getFolders().getMyDir().getMyFile());
                newUser = new MailUserOperations(rootFolders.getRoot().getMyFile(), userAccount);
                newUser.setUser(userMail);
                users.writeUsersFile();
                if (newUser != null) {
                    newUser.writeContactFile();
                    newUser.writeFilterFile();
                }
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }
}//GEN-LAST:event_jButton1MouseClicked
    String gender;
    private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton1ActionPerformed
        // TODO add your handling code here:
        gender=jRadioButton1.getText();
    }//GEN-LAST:event_jRadioButton1ActionPerformed

    private void jComboBox3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox3ActionPerformed
        // TODO add your handling code here:
        day=(String)jComboBox3.getSelectedItem();
    }//GEN-LAST:event_jComboBox3ActionPerformed

    private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton2ActionPerformed
        // TODO add your handling code here:
        gender=jRadioButton2.getText();
    }//GEN-LAST:event_jRadioButton2ActionPerformed


    private void jTextField5FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField5FocusLost
        // TODO add your handling code here:
        String firstName = jTextField5.getText();
        int status = Validate.validateName(firstName, 3);
        if (status < 0) {
            if (status == -1) {
                jLabel33.setVisible(true);
                nameStatus=-1;
            }
            if (status == -2) {
                jLabel32.setVisible(true);
                nameStatus=-1;
            }
        } else {
            nameStatus=0;
            jLabel32.setVisible(false);
            jLabel33.setVisible(false);
        }
    }//GEN-LAST:event_jTextField5FocusLost

    private void jTextField1FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField1FocusLost
        // TODO add your handling code here:
        String id = jTextField1.getText();
        int status = Validate.validateId(id, 4);
        generalStatus+=status;
        if (status < 0) {
            if (status == -1) {
                idStatus=-1;
                jLabel30.setVisible(true);
            }
            if (status == -2) {
                idStatus=-1;
                jLabel31.setVisible(true);
            }
        } else {
            idStatus=0;
            jLabel31.setVisible(false);
            jLabel30.setVisible(false);
        }

    }//GEN-LAST:event_jTextField1FocusLost

    private void jTextField4FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField4FocusLost
        // TODO add your handling code here:
        String lastName = jTextField4.getText();
        int status = Validate.validateName(lastName, 3);
        jLabel32.setVisible(false);
        jLabel33.setVisible(false);
        if (status < 0) {
            if (status == -1) {
                jLabel33.setVisible(true);
                nameStatus=-1;
            }
            if (status == -2) {
                jLabel32.setVisible(true);
                nameStatus=-1;
            }
        } else {
            nameStatus=0;
            jLabel32.setVisible(false);
            jLabel33.setVisible(false);
        }
    }//GEN-LAST:event_jTextField4FocusLost

    private void jTextField7FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField7FocusLost
        // TODO add your handling code here:
        String secQn = jTextField7.getText();
        int status = Validate.validateSecQn(secQn, 8);
        jLabel34.setVisible(false);
        jLabel35.setVisible(false);
        if (status < 0) {
            if (status == -1) {
                jLabel34.setVisible(true);
                secQnStatus=-1;
            }
            if (status == -2) {
                secQnStatus=-1;
                jLabel35.setVisible(true);
            }
        } else {
            secQnStatus=0;
            jLabel34.setVisible(false);
            jLabel35.setVisible(false);
        }
    }//GEN-LAST:event_jTextField7FocusLost

    private void jTextField2FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField2FocusLost
        // TODO add your handling code here:
        String country = jTextField2.getText();
        int status = Validate.validateCountry(country, 2);
        jLabel37.setVisible(false);
        jLabel38.setVisible(false);
        if (status < 0) {
            if (status == -1) {
                jLabel37.setVisible(true);
                countryStatus=-1;
            }
            if (status == -2) {
                countryStatus=-1;
                jLabel38.setVisible(true);
            }
        } else {
            countryStatus=0;
            jLabel37.setVisible(false);
            jLabel38.setVisible(false);
        }
}//GEN-LAST:event_jTextField2FocusLost

    private void jTextField6FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField6FocusLost
        // TODO add your handling code here:
        String city = jTextField6.getText();
        int status = Validate.validateCity(city, 1);
        jLabel39.setVisible(false);
        jLabel40.setVisible(false);
        if (status < 0) {
            if (status == -1) {
                jLabel39.setVisible(true);
                cityStatus=-1;
            }
            if (status == -2) {
                cityStatus=-1;
                jLabel40.setVisible(true);
            }
        } else {
            cityStatus=0;
            jLabel39.setVisible(false);
            jLabel40.setVisible(false);
        }
    }//GEN-LAST:event_jTextField6FocusLost

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        // TODO add your handling code here:
        int itemIndex=jComboBox2.getSelectedIndex();
        String[] dayList=Validate.dayList(itemIndex,jComboBox1.getSelectedIndex());
        jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(dayList));
        year=(String)jComboBox1.getSelectedItem();
        month=(String)jComboBox2.getSelectedItem();
        day=(String)jComboBox3.getSelectedItem();
        idStatus=-1;
        passStatus=-1;
        nameStatus=-1;
        secQnStatus=-1;
        emailStatus=-1;
        countryStatus=-1;
        cityStatus=-1;
        secImageStatus=-1;
        postalCodeStatus=-1;
        genderStatus=-1;
        generalStatus=(passStatus+nameStatus+secQnStatus+secAnsStatus+emailStatus+countryStatus+cityStatus+secImageStatus+postalCodeStatus+genderStatus+idStatus);
        
    }//GEN-LAST:event_formWindowOpened

    private void jTextField10FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField10FocusLost
        // TODO add your handling code here:
        String postalCode = jTextField10.getText();
        int status = Validate.validateCity(postalCode, 5);
        jLabel41.setVisible(false);
        if (status < 0) {
            postalCodeStatus=-1;
            jLabel41.setVisible(true);
        } else {
            postalCodeStatus=0;
            jLabel41.setVisible(false);
        }
    }//GEN-LAST:event_jTextField10FocusLost

    private void jTextField11FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField11FocusLost
        // TODO add your handling code here:
        String secImage=jTextField11.getText();
        int status=Validate.validateSecImage(secImage, "nwbuygwn");
        if (status==-1){
            secImageStatus=-1;
            jLabel42.setVisible(true);
        }else{
            secImageStatus=0;
            jLabel42.setVisible(false);
        }
    }//GEN-LAST:event_jTextField11FocusLost

    private void jTextField9FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField9FocusLost
        // TODO add your handling code here:
       int status=Validate.validateSecAns(jTextField9.getText(), 4);
        jLabel43.setVisible(false);
        jLabel44.setVisible(false);
        if (status < 0) {
            if (status == -1) {
                jLabel43.setVisible(true);
                secAnsStatus = -1;
            }
            if (status == -2) {
                secAnsStatus = -1;
                jLabel44.setVisible(true);
            }
        } else {
            secAnsStatus = 0;
            jLabel43.setVisible(false);
            jLabel44.setVisible(false);
        }

    }//GEN-LAST:event_jTextField9FocusLost


    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new CretaeAccount().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JComboBox jComboBox3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel35;
    private javax.swing.JLabel jLabel36;
    private javax.swing.JLabel jLabel37;
    private javax.swing.JLabel jLabel38;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel40;
    private javax.swing.JLabel jLabel41;
    private javax.swing.JLabel jLabel42;
    private javax.swing.JLabel jLabel43;
    private javax.swing.JLabel jLabel44;
    private volatile javax.swing.JLabel jLabel45;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPasswordField jPasswordField1;
    private javax.swing.JPasswordField jPasswordField2;
    private javax.swing.JRadioButton jRadioButton1;
    private javax.swing.JRadioButton jRadioButton2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField10;
    private javax.swing.JTextField jTextField11;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField6;
    private javax.swing.JTextField jTextField7;
    private javax.swing.JTextField jTextField9;
    // End of variables declaration//GEN-END:variables

}
